package com.sql;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class UserCheck {
	public boolean checkPass(String name,String psd) {
		boolean light = false;
		
		Connection connection;
		Statement statement = null;
		ResultSet rSet = null;
		String sql = "select * from user where username = '"+name+"' and password = '"+psd+"' ";
		SqlManege sManege = new SqlManege();
		connection = sManege.doInit();
		try {
			statement = connection.createStatement();
			rSet = statement.executeQuery(sql);
			while(rSet.next()){
				light = true;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally {
			sManege.dbclose(connection, statement, rSet);
		}
		
		return light;
	}
	public boolean checkOnly(String name){
		boolean light = true;
		
		Connection connection;
		Statement statement = null;
		ResultSet rSet = null;
		String sql = "select * from user where username = '"+name+"' ";
		SqlManege sManege = new SqlManege();
		connection = sManege.doInit();
		try {
			statement = connection.createStatement();
			rSet = statement.executeQuery(sql);
			while(rSet.next()){
				light = false;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		finally {
			sManege.dbclose(connection, statement, rSet);
		}
		
		return light;
	}
}
